package sctu.edu.java.year2016.team01.zhuming.day20160605.practice;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by Administrator on 2016/6/5.
 */
public class DiDaiQi {
    public static void main(String[] args) {
        String a="A",b="B",c="C",d="D",e="E";
        List<String> list=new LinkedList<String>();
        list.add(a);
        list.add(e);
        list.add(d);
        Iterator<String>fisrtIterator=list.iterator();//创建迭代器
        System.out.println("修改前的元素是：");
        while (fisrtIterator.hasNext())//hasnext 是否有下一条记录，如果有就读出，否则就就退出当前循环；
            System.out.println(fisrtIterator.next()+ " ");
        list.set(2, b);
        list.add(1, c);
        Iterator<String> it=list.iterator();
        System.out.println("输出后的元素是：");
                while(it.hasNext())
                    System.out.println("   "+it.next());

    }



}
